package bo;

import IBO.IRole;
import dao.dto.RoleDto;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Role implements IRole, Cloneable{
        private boolean _gestionClient;
        private boolean _gestionIntervention;
        private boolean _gestionPlanning;
        private boolean _gestionDirection;
        private boolean _gestionOnSite;
        private boolean _gestionSys;
    
	//*******************************************************************
	//Constructeurs
	//*******************************************************************

        public Role(RoleDto role) throws RemoteException{
            this._gestionClient = role.getGestionClient();
            this._gestionDirection = role.getGestionDirection();
            this._gestionIntervention = role.getGestionIntervention();
            this._gestionOnSite = role.getGestionOnSite();
            this._gestionPlanning = role.getGestionPlanning();
            this._gestionSys = role.getGestionSysteme();
            UnicastRemoteObject.exportObject(this, 0);
        }
        
        public Role(boolean gestionClient, boolean gestionDirection, boolean gestionIntervention, 
                    boolean gestionOnSite, boolean gestionPlanning, boolean gestionSys) throws RemoteException {
                this._gestionClient = gestionClient;
                this._gestionIntervention = gestionIntervention;
                this._gestionPlanning = gestionPlanning;
                this._gestionDirection = gestionDirection;
                this._gestionOnSite = gestionOnSite;
                this._gestionSys = gestionSys;
                UnicastRemoteObject.exportObject(this,0);
        }        

        //*******************************************************************
        //Convertir bo - dto
	//*******************************************************************
        
        public RoleDto creerRoleDto() {
                return new RoleDto( this.isGestionClient(), this.isGestionDirection(),
                                    this.isGestionIntervention(),this.isGestionOnSite(),
                                    this.isGestionPlanning(),this.isGestionSys());
        }

	//*******************************************************************
	//Setters
	//*******************************************************************
        
        public synchronized void set_gestionClient(boolean gestionClient) {
                this._gestionClient = gestionClient;
        }

        public synchronized void set_gestionDirection(boolean gestionDirection) {
                this._gestionDirection = gestionDirection;
        }
    
        public synchronized void set_gestionIntervention(boolean gestionIntervention) {
                this._gestionIntervention = gestionIntervention;
        }

        public synchronized void set_gestionPlanning(boolean gestionPlanning) {
                this._gestionPlanning = gestionPlanning;
        }

        public synchronized void set_gestionOnSite(boolean gestionOnSite) {
                this._gestionOnSite = gestionOnSite;
        }
    
        public synchronized void set_gestionSys(boolean gestionSys) {
                this._gestionSys = gestionSys;
        }   
    
	//*******************************************************************
	//Getters
	//*******************************************************************
        
        public synchronized boolean isGestionClient(){
                return _gestionClient;
        }    
    
        public synchronized boolean isGestionDirection() {
                return _gestionDirection;
        }

        public synchronized boolean isGestionIntervention() {
                return _gestionIntervention;
        }

        public synchronized boolean isGestionPlanning() {
                return _gestionPlanning;
        }

        public synchronized boolean isGestionOnSite() {
                return this._gestionOnSite;
        }    
    
        public synchronized boolean isGestionSys() {
                return _gestionSys;
        }

        //*******************************************************************
	//Method Clonable
	//*******************************************************************        
        
        @Override
        public Object clone(){
            Role role = null;
            try {
                role = (Role) super.clone();
                // on renvoie le clone
                return role;
            } catch (CloneNotSupportedException ex) {
                Logger.getLogger(Role.class.getName()).log(Level.SEVERE, null, ex);
            }
            return role;
        } 
}